package com.itheima.Service.ServiceImpl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.Service.UserPetService;
import com.itheima.mapper.UserPetMapper;
import com.itheima.pojo.PageBean;
import com.itheima.pojo.Pet;
import com.itheima.pojo.PetDesc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class UserPetServiceImpl implements UserPetService {
    @Autowired
    private UserPetMapper userPetMapper;
    @Override
    public PageBean page(Integer page, Integer pageSize, String species, Integer storeId, LocalDateTime begin, LocalDateTime end) {
        PageHelper.startPage(page,pageSize);
        Page<Pet> petPage = userPetMapper.page(species,storeId,begin,end);
        return new PageBean(petPage.getTotal(),petPage.getResult());
    }

    @Override
    public PetDesc selectById(Integer id) {
        PetDesc pet = userPetMapper.selectById(id);
        return pet;
    }
}
